{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n# Transformations Tutorial\n\n\nLike any graphics packages, Matplotlib is built on top of a\ntransformation framework to easily move between coordinate systems,\nthe userland `data` coordinate system, the `axes` coordinate system,\nthe `figure` coordinate system, and the `display` coordinate system.\nIn 95% of your plotting, you won't need to think about this, as it\nhappens under the hood, but as you push the limits of custom figure\ngeneration, it helps to have an understanding of these objects so you\ncan reuse the existing transformations Matplotlib makes available to\nyou, or create your own (see :mod:`matplotlib.transforms`).  The table\nbelow summarizes the some useful coordinate systems, the transformation\nobject you should use to work in that coordinate system, and the\ndescription of that system. In the `Transformation Object` column,\n``ax`` is a :class:`~matplotlib.axes.Axes` instance, and ``fig`` is a\n:class:`~matplotlib.figure.Figure` instance.\n\n+----------------+-----------------------------+-----------------------------------+\n|Coordinates     |Transformation object        |Description                        |\n+================+=============================+===================================+\n|\"data\"          |``ax.transData``             |The coordinate system for the data,|\n|                |                             |controlled by xlim and ylim.       |\n+----------------+-----------------------------+-----------------------------------+\n|\"axes\"          |``ax.transAxes``             |The coordinate system of the       |\n|                |                             |`~matplotlib.axes.Axes`; (0, 0)    |\n|                |                             |is bottom left of the axes, and    |\n|                |                             |(1, 1) is top right of the axes.   |\n+----------------+-----------------------------+-----------------------------------+\n|\"figure\"        |``fig.transFigure``          |The coordinate system of the       |\n|                |                             |`.Figure`; (0, 0) is bottom left   |\n|                |                             |of the figure, and (1, 1) is top   |\n|                |                             |right of the figure.               |\n+----------------+-----------------------------+-----------------------------------+\n|\"figure-inches\" |``fig.dpi_scale_trans``      |The coordinate system of the       |\n|                |                             |`.Figure` in inches; (0, 0) is     |\n|                |                             |bottom left of the figure, and     |\n|                |                             |(width, height) is the top right   |\n|                |                             |of the figure in inches.           |\n+----------------+-----------------------------+-----------------------------------+\n|\"display\"       |``None``, or                 |The pixel coordinate system of the |\n|                |``IdentityTransform()``      |display window; (0, 0) is bottom   |\n|                |                             |left of the window, and (width,    |\n|                |                             |height) is top right of the        |\n|                |                             |display window in pixels.          |\n+----------------+-----------------------------+-----------------------------------+\n|\"xaxis\",        |``ax.get_xaxis_transform()``,|Blended coordinate systems; use    |\n|\"yaxis\"         |``ax.get_yaxis_transform()`` |data coordinates on one of the axis|\n|                |                             |and axes coordinates on the other. |\n+----------------+-----------------------------+-----------------------------------+\n\nAll of the transformation objects in the table above take inputs in\ntheir coordinate system, and transform the input to the ``display``\ncoordinate system.  That is why the ``display`` coordinate system has\n``None`` for the ``Transformation Object`` column -- it already is in\ndisplay coordinates.  The transformations also know how to invert\nthemselves, to go from ``display`` back to the native coordinate system.\nThis is particularly useful when processing events from the user\ninterface, which typically occur in display space, and you want to\nknow where the mouse click or key-press occurred in your data\ncoordinate system.\n\nNote that specifying objects in ``display`` coordinates will change their\nlocation if the ``dpi`` of the figure changes.  This can cause confusion when\nprinting or changing screen resolution, because the object can change location\nand size.  Therefore it is most common\nfor artists placed in an axes or figure to have their transform set to\nsomething *other* than the `~.transforms.IdentityTransform()`; the default when\nan artist is placed on an axes using `~.Axes.axes.add_artist` is for the\ntransform to be ``ax.transData``.\n\n\nData coordinates\n================\n\nLet's start with the most commonly used coordinate, the `data`\ncoordinate system.  Whenever you add data to the axes, Matplotlib\nupdates the datalimits, most commonly updated with the\n:meth:`~matplotlib.axes.Axes.set_xlim` and\n:meth:`~matplotlib.axes.Axes.set_ylim` methods.  For example, in the\nfigure below, the data limits stretch from 0 to 10 on the x-axis, and\n-1 to 1 on the y-axis.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as mpatches\n\nx = np.arange(0, 10, 0.005)\ny = np.exp(-x/2.) * np.sin(2*np.pi*x)\n\nfig, ax = plt.subplots()\nax.plot(x, y)\nax.set_xlim(0, 10)\nax.set_ylim(-1, 1)\n\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can use the ``ax.transData`` instance to transform from your\n`data` to your `display` coordinate system, either a single point or a\nsequence of points as shown below:\n\n.. sourcecode:: ipython\n\n    In [14]: type(ax.transData)\n    Out[14]: <class 'matplotlib.transforms.CompositeGenericTransform'>\n\n    In [15]: ax.transData.transform((5, 0))\n    Out[15]: array([ 335.175,  247.   ])\n\n    In [16]: ax.transData.transform([(5, 0), (1, 2)])\n    Out[16]:\n    array([[ 335.175,  247.   ],\n           [ 132.435,  642.2  ]])\n\nYou can use the :meth:`~matplotlib.transforms.Transform.inverted`\nmethod to create a transform which will take you from display to data\ncoordinates:\n\n.. sourcecode:: ipython\n\n    In [41]: inv = ax.transData.inverted()\n\n    In [42]: type(inv)\n    Out[42]: <class 'matplotlib.transforms.CompositeGenericTransform'>\n\n    In [43]: inv.transform((335.175,  247.))\n    Out[43]: array([ 5.,  0.])\n\nIf your are typing along with this tutorial, the exact values of the\ndisplay coordinates may differ if you have a different window size or\ndpi setting.  Likewise, in the figure below, the display labeled\npoints are probably not the same as in the ipython session because the\ndocumentation figure size defaults are different.\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "x = np.arange(0, 10, 0.005)\ny = np.exp(-x/2.) * np.sin(2*np.pi*x)\n\nfig, ax = plt.subplots()\nax.plot(x, y)\nax.set_xlim(0, 10)\nax.set_ylim(-1, 1)\n\nxdata, ydata = 5, 0\nxdisplay, ydisplay = ax.transData.transform_point((xdata, ydata))\n\nbbox = dict(boxstyle=\"round\", fc=\"0.8\")\narrowprops = dict(\n    arrowstyle=\"->\",\n    connectionstyle=\"angle,angleA=0,angleB=90,rad=10\")\n\noffset = 72\nax.annotate('data = (%.1f, %.1f)' % (xdata, ydata),\n            (xdata, ydata), xytext=(-2*offset, offset), textcoords='offset points',\n            bbox=bbox, arrowprops=arrowprops)\n\ndisp = ax.annotate('display = (%.1f, %.1f)' % (xdisplay, ydisplay),\n                   (xdisplay, ydisplay), xytext=(0.5*offset, -offset),\n                   xycoords='figure pixels',\n                   textcoords='offset points',\n                   bbox=bbox, arrowprops=arrowprops)\n\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-info\"><h4>Note</h4><p>If you run the source code in the example above in a GUI backend,\n  you may also find that the two arrows for the `data` and `display`\n  annotations do not point to exactly the same point.  This is because\n  the display point was computed before the figure was displayed, and\n  the GUI backend may slightly resize the figure when it is created.\n  The effect is more pronounced if you resize the figure yourself.\n  This is one good reason why you rarely want to work in display\n  space, but you can connect to the ``'on_draw'``\n  :class:`~matplotlib.backend_bases.Event` to update figure\n  coordinates on figure draws; see `event-handling-tutorial`.</p></div>\n\nWhen you change the x or y limits of your axes, the data limits are\nupdated so the transformation yields a new display point.  Note that\nwhen we just change the ylim, only the y-display coordinate is\naltered, and when we change the xlim too, both are altered.  More on\nthis later when we talk about the\n:class:`~matplotlib.transforms.Bbox`.\n\n.. sourcecode:: ipython\n\n    In [54]: ax.transData.transform((5, 0))\n    Out[54]: array([ 335.175,  247.   ])\n\n    In [55]: ax.set_ylim(-1, 2)\n    Out[55]: (-1, 2)\n\n    In [56]: ax.transData.transform((5, 0))\n    Out[56]: array([ 335.175     ,  181.13333333])\n\n    In [57]: ax.set_xlim(10, 20)\n    Out[57]: (10, 20)\n\n    In [58]: ax.transData.transform((5, 0))\n    Out[58]: array([-171.675     ,  181.13333333])\n\n\n\nAxes coordinates\n================\n\nAfter the `data` coordinate system, `axes` is probably the second most\nuseful coordinate system.  Here the point (0, 0) is the bottom left of\nyour axes or subplot, (0.5, 0.5) is the center, and (1.0, 1.0) is the\ntop right.  You can also refer to points outside the range, so (-0.1,\n1.1) is to the left and above your axes.  This coordinate system is\nextremely useful when placing text in your axes, because you often\nwant a text bubble in a fixed, location, e.g., the upper left of the axes\npane, and have that location remain fixed when you pan or zoom.  Here\nis a simple example that creates four panels and labels them 'A', 'B',\n'C', 'D' as you often see in journals.\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig = plt.figure()\nfor i, label in enumerate(('A', 'B', 'C', 'D')):\n    ax = fig.add_subplot(2, 2, i+1)\n    ax.text(0.05, 0.95, label, transform=ax.transAxes,\n            fontsize=16, fontweight='bold', va='top')\n\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also make lines or patches in the axes coordinate system, but\nthis is less useful in my experience than using ``ax.transAxes`` for\nplacing text.  Nonetheless, here is a silly example which plots some\nrandom dots in `data` space, and overlays a semi-transparent\n:class:`~matplotlib.patches.Circle` centered in the middle of the axes\nwith a radius one quarter of the axes -- if your axes does not\npreserve aspect ratio (see :meth:`~matplotlib.axes.Axes.set_aspect`),\nthis will look like an ellipse.  Use the pan/zoom tool to move around,\nor manually change the data xlim and ylim, and you will see the data\nmove, but the circle will remain fixed because it is not in `data`\ncoordinates and will always remain at the center of the axes.\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\nx, y = 10*np.random.rand(2, 1000)\nax.plot(x, y, 'go', alpha=0.2)  # plot some data in data coordinates\n\ncirc = mpatches.Circle((0.5, 0.5), 0.25, transform=ax.transAxes,\n                       facecolor='blue', alpha=0.75)\nax.add_patch(circ)\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\nBlended transformations\n=======================\n\nDrawing in `blended` coordinate spaces which mix `axes` with `data`\ncoordinates is extremely useful, for example to create a horizontal\nspan which highlights some region of the y-data but spans across the\nx-axis regardless of the data limits, pan or zoom level, etc.  In fact\nthese blended lines and spans are so useful, we have built in\nfunctions to make them easy to plot (see\n:meth:`~matplotlib.axes.Axes.axhline`,\n:meth:`~matplotlib.axes.Axes.axvline`,\n:meth:`~matplotlib.axes.Axes.axhspan`,\n:meth:`~matplotlib.axes.Axes.axvspan`) but for didactic purposes we\nwill implement the horizontal span here using a blended\ntransformation.  This trick only works for separable transformations,\nlike you see in normal Cartesian coordinate systems, but not on\ninseparable transformations like the\n:class:`~matplotlib.projections.polar.PolarAxes.PolarTransform`.\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import matplotlib.transforms as transforms\n\nfig, ax = plt.subplots()\nx = np.random.randn(1000)\n\nax.hist(x, 30)\nax.set_title(r'$\\sigma=1 \\/ \\dots \\/ \\sigma=2$', fontsize=16)\n\n# the x coords of this transformation are data, and the\n# y coord are axes\ntrans = transforms.blended_transform_factory(\n    ax.transData, ax.transAxes)\n\n# highlight the 1..2 stddev region with a span.\n# We want x to be in data coordinates and y to\n# span from 0..1 in axes coords\nrect = mpatches.Rectangle((1, 0), width=1, height=1,\n                         transform=trans, color='yellow',\n                         alpha=0.5)\n\nax.add_patch(rect)\n\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-info\"><h4>Note</h4><p>The blended transformations where x is in data coords and y in axes\n  coordinates is so useful that we have helper methods to return the\n  versions mpl uses internally for drawing ticks, ticklabels, etc.\n  The methods are :meth:`matplotlib.axes.Axes.get_xaxis_transform` and\n  :meth:`matplotlib.axes.Axes.get_yaxis_transform`.  So in the example\n  above, the call to\n  :meth:`~matplotlib.transforms.blended_transform_factory` can be\n  replaced by ``get_xaxis_transform``::\n\n    trans = ax.get_xaxis_transform()</p></div>\n\n\nPlotting in physical units\n==========================\n\nSometimes we want an object to be a certain physical size on the plot.\nHere we draw the same circle as above, but in physical units.  If done\ninteractively, you can see that changing the size of the figure does\nnot change the offset of the circle from the lower-left corner,\ndoes not change its size, and the circle remains a circle regardless of\nthe aspect ratio of the axes.\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots(figsize=(5, 4))\nx, y = 10*np.random.rand(2, 1000)\nax.plot(x, y*10., 'go', alpha=0.2)  # plot some data in data coordinates\n# add a circle in fixed-units\ncirc = mpatches.Circle((2.5, 2), 1.0, transform=fig.dpi_scale_trans,\n                       facecolor='blue', alpha=0.75)\nax.add_patch(circ)\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we change the figure size, the circle does not change its absolute\nposition and is cropped.\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots(figsize=(7, 2))\nx, y = 10*np.random.rand(2, 1000)\nax.plot(x, y*10., 'go', alpha=0.2)  # plot some data in data coordinates\n# add a circle in fixed-units\ncirc = mpatches.Circle((2.5, 2), 1.0, transform=fig.dpi_scale_trans,\n                       facecolor='blue', alpha=0.75)\nax.add_patch(circ)\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Another use is putting a patch with a set physical dimension around a\ndata point on the axes.  Here we add together two transforms.  The\nfirst sets the scaling of how large the ellipse should be and the second\nsets its position.  The ellipse is then placed at the origin, and then\nwe use the helper transform :class:`~matplotlib.transforms.ScaledTranslation`\nto move it\nto the right place in the ``ax.transData`` coordinate system.\nThis helper is instantiated with::\n\n  trans = ScaledTranslation(xt, yt, scale_trans)\n\nwhere `xt` and `yt` are the translation offsets, and `scale_trans` is\na transformation which scales `xt` and `yt` at transformation time\nbefore applying the offsets.\n\nNote the use of the plus operator on the transforms below.\nThis code says: first apply the scale transformation ``fig.dpi_scale_trans``\nto make the ellipse the proper size, but still centered at (0, 0),\nand then translate the data to `xdata[0]` and `ydata[0]` in data space.\n\nIn interactive use, the ellipse stays the same size even if the\naxes limits are changed via zoom.\n\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\nxdata, ydata = (0.2, 0.7), (0.5, 0.5)\nax.plot(xdata, ydata, \"o\")\nax.set_xlim((0, 1))\n\ntrans = (fig.dpi_scale_trans +\n         transforms.ScaledTranslation(xdata[0], ydata[0], ax.transData))\n\n# plot an ellipse around the point that is 150 x 130 points in diameter...\ncircle = mpatches.Ellipse((0, 0), 150/72, 130/72, angle=40,\n                          fill=None, transform=trans)\nax.add_patch(circle)\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-info\"><h4>Note</h4><p>The order of transformation matters.  Here the ellipse\n  is given the right dimensions in display space *first* and then moved\n  in data space to the correct spot.\n  If we had done the ``ScaledTranslation`` first, then\n  ``xdata[0]`` and ``ydata[0]`` would\n  first be transformed to ``display`` coordinates (``[ 358.4  475.2]`` on\n  a 200-dpi monitor) and then those coordinates\n  would be scaled by ``fig.dpi_scale_trans`` pushing the center of\n  the ellipse well off the screen (i.e. ``[ 71680.  95040.]``).</p></div>\n\n\nUsing offset transforms to create a shadow effect\n=================================================\n\nAnother use of :class:`~matplotlib.transforms.ScaledTranslation` is to create\na new transformation that is\noffset from another transformation, e.g., to place one object shifted a\nbit relative to another object.  Typically you want the shift to be in\nsome physical dimension, like points or inches rather than in data\ncoordinates, so that the shift effect is constant at different zoom\nlevels and dpi settings.\n\nOne use for an offset is to create a shadow effect, where you draw one\nobject identical to the first just to the right of it, and just below\nit, adjusting the zorder to make sure the shadow is drawn first and\nthen the object it is shadowing above it.\n\nHere we apply the transforms in the *opposite* order to the use of\n:class:`~matplotlib.transforms.ScaledTranslation` above. The plot is\nfirst made in data units (``ax.transData``) and then shifted by\n``dx`` and ``dy`` points using `fig.dpi_scale_trans`.  (In typography,\na`point <https://en.wikipedia.org/wiki/Point_%28typography%29>`_ is\n1/72 inches, and by specifying your offsets in points, your figure\nwill look the same regardless of the dpi resolution it is saved in.)\n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n\n# make a simple sine wave\nx = np.arange(0., 2., 0.01)\ny = np.sin(2*np.pi*x)\nline, = ax.plot(x, y, lw=3, color='blue')\n\n# shift the object over 2 points, and down 2 points\ndx, dy = 2/72., -2/72.\noffset = transforms.ScaledTranslation(dx, dy, fig.dpi_scale_trans)\nshadow_transform = ax.transData + offset\n\n# now plot the same data with our offset transform;\n# use the zorder to make sure we are below the line\nax.plot(x, y, lw=3, color='gray',\n        transform=shadow_transform,\n        zorder=0.5*line.get_zorder())\n\nax.set_title('creating a shadow effect with an offset transform')\nplt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-info\"><h4>Note</h4><p>The dpi and inches offset is a\n  common-enough use case that we have a special helper function to\n  create it in :func:`matplotlib.transforms.offset_copy`, which returns\n  a new transform with an added offset. So above we could have done::\n\n     shadow_transform = transforms.offset_copy(ax.transData,\n              fig=fig, dx, dy, units='inches')</p></div>\n\n\n\nThe transformation pipeline\n===========================\n\nThe ``ax.transData`` transform we have been working with in this\ntutorial is a composite of three different transformations that\ncomprise the transformation pipeline from `data` -> `display`\ncoordinates.  Michael Droettboom implemented the transformations\nframework, taking care to provide a clean API that segregated the\nnonlinear projections and scales that happen in polar and logarithmic\nplots, from the linear affine transformations that happen when you pan\nand zoom.  There is an efficiency here, because you can pan and zoom\nin your axes which affects the affine transformation, but you may not\nneed to compute the potentially expensive nonlinear scales or\nprojections on simple navigation events.  It is also possible to\nmultiply affine transformation matrices together, and then apply them\nto coordinates in one step.  This is not true of all possible\ntransformations.\n\n\nHere is how the ``ax.transData`` instance is defined in the basic\nseparable axis :class:`~matplotlib.axes.Axes` class::\n\n  self.transData = self.transScale + (self.transLimits + self.transAxes)\n\nWe've been introduced to the ``transAxes`` instance above in\n`axes-coords`, which maps the (0, 0), (1, 1) corners of the\naxes or subplot bounding box to `display` space, so let's look at\nthese other two pieces.\n\n``self.transLimits`` is the transformation that takes you from\n``data`` to ``axes`` coordinates; i.e., it maps your view xlim and ylim\nto the unit space of the axes (and ``transAxes`` then takes that unit\nspace to display space).  We can see this in action here\n\n.. sourcecode:: ipython\n\n    In [80]: ax = subplot(111)\n\n    In [81]: ax.set_xlim(0, 10)\n    Out[81]: (0, 10)\n\n    In [82]: ax.set_ylim(-1, 1)\n    Out[82]: (-1, 1)\n\n    In [84]: ax.transLimits.transform((0, -1))\n    Out[84]: array([ 0.,  0.])\n\n    In [85]: ax.transLimits.transform((10, -1))\n    Out[85]: array([ 1.,  0.])\n\n    In [86]: ax.transLimits.transform((10, 1))\n    Out[86]: array([ 1.,  1.])\n\n    In [87]: ax.transLimits.transform((5, 0))\n    Out[87]: array([ 0.5,  0.5])\n\nand we can use this same inverted transformation to go from the unit\n`axes` coordinates back to `data` coordinates.\n\n.. sourcecode:: ipython\n\n    In [90]: inv.transform((0.25, 0.25))\n    Out[90]: array([ 2.5, -0.5])\n\nThe final piece is the ``self.transScale`` attribute, which is\nresponsible for the optional non-linear scaling of the data, e.g., for\nlogarithmic axes.  When an Axes is initially setup, this is just set to\nthe identity transform, since the basic Matplotlib axes has linear\nscale, but when you call a logarithmic scaling function like\n:meth:`~matplotlib.axes.Axes.semilogx` or explicitly set the scale to\nlogarithmic with :meth:`~matplotlib.axes.Axes.set_xscale`, then the\n``ax.transScale`` attribute is set to handle the nonlinear projection.\nThe scales transforms are properties of the respective ``xaxis`` and\n``yaxis`` :class:`~matplotlib.axis.Axis` instances.  For example, when\nyou call ``ax.set_xscale('log')``, the xaxis updates its scale to a\n:class:`matplotlib.scale.LogScale` instance.\n\nFor non-separable axes the PolarAxes, there is one more piece to\nconsider, the projection transformation.  The ``transData``\n:class:`matplotlib.projections.polar.PolarAxes` is similar to that for\nthe typical separable matplotlib Axes, with one additional piece\n``transProjection``::\n\n      self.transData = self.transScale + self.transProjection + \\\n          (self.transProjectionAffine + self.transAxes)\n\n``transProjection`` handles the projection from the space,\ne.g., latitude and longitude for map data, or radius and theta for polar\ndata, to a separable Cartesian coordinate system.  There are several\nprojection examples in the ``matplotlib.projections`` package, and the\nbest way to learn more is to open the source for those packages and\nsee how to make your own, since Matplotlib supports extensible axes\nand projections.  Michael Droettboom has provided a nice tutorial\nexample of creating a Hammer projection axes; see\n:doc:`/gallery/misc/custom_projection`.\n\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
